package wordsort.test;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class WSMapper extends Mapper<LongWritable, Text, IntWritable, IntWritable> {

    final IntWritable word = new IntWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String num = value.toString();
        word.set(Integer.parseInt(num));
        //mapper output: num,num
        context.write(new IntWritable(word.get()), new IntWritable(word.get()));
    }
}
